﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000052 RID: 82
	public class NullableDateTimeFormatter : IMessagePackFormatter<DateTime?>
	{
		// Token: 0x06000137 RID: 311 RVA: 0x00004E40 File Offset: 0x00003240
		private NullableDateTimeFormatter()
		{
		}

		// Token: 0x06000138 RID: 312 RVA: 0x00004E48 File Offset: 0x00003248
		public int Serialize(ref byte[] bytes, int offset, DateTime? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteDateTime(ref bytes, offset, value.Value);
		}

		// Token: 0x06000139 RID: 313 RVA: 0x00004E70 File Offset: 0x00003270
		public DateTime? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new DateTime?(MessagePackBinary.ReadDateTime(bytes, offset, out readSize));
		}

		// Token: 0x04000046 RID: 70
		public static readonly NullableDateTimeFormatter Instance = new NullableDateTimeFormatter();
	}
}
